﻿using System.Collections.Generic;
using System.Linq;
using LINQtoFxCop.Core;

namespace LINQtoFxCop.Flaws.Implementation
{
  internal sealed class ImplementationObjectNotProvidedByFactory : FlawsIntrospectionRule
  {
    public ImplementationObjectNotProvidedByFactory()
      : base("ImplementationObjectNotProvidedByFactory")
    { }

    protected override IEnumerable<QueryResult> Query()
    {
      return
        from method in Methods
        where !method.DeclaringType.IsSubTypeOf("AnalysisTarget.Defects.Implementation.MyFactory") &&
              method.CreatesNewType("AnalysisTarget.Defects.Implementation.MyClass")
        select Result(method);
    }
  }
}